package com.stateflow.facade.common.model.res;

import com.stateflow.facade.common.enums.CommonErrorEnum;
import com.stateflow.facade.common.model.ToString;

/**
 * Created by weiqingming on 2019/4/16.
 */
public class CommonResult<T> extends ToString{

    /** 成功标识 */
    protected Boolean success = true;

    /** 错误码 */
    protected String errorCode;

    /** 错误描述 */
    protected String errorMsg;

    /** 返回数据 */
    protected T data;

    public CommonResult(){}


    public CommonResult(T data){
        this.data = data;
    }

    public CommonResult(String errorCode,String errorMsg){
        this.success = false;
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public CommonResult(CommonErrorEnum errorEnum){
        this.success = false;
        this.errorCode = errorEnum.getCode();
        this.errorMsg = errorEnum.getDesc();
    }

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public <T> T getData() {
        return (T) data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
